from starlette.endpoints import HTTPEndpoint
from starlette.responses import JSONResponse
from model.ModStationMonRep import StationMonRep, stationMonRepSchema
from database import Session, engine
import datetime
from sqlalchemy import Date, DateTime


def get_monthrep_info(session, bureauid: str, monthnum: Date):
    # 根据县局，月份查询供电所指标排名月报
    monthrep_info = session.query(StationMonRep).filter(StationMonRep.bureauid == bureauid).filter(
        StationMonRep.monthnum == monthnum).order_by(StationMonRep.stationid.asc()).all()
    return JSONResponse(stationMonRepSchema.dump(monthrep_info, many=True).data)
